package com.zt.springcloud.service.Impl;

import cloud.zt.springboot.utils.TokenUtils;
import com.zt.springcloud.RemoteOrderService;
import com.zt.springcloud.RemoteUserService;
import com.zt.springcloud.entity.Vo.OrderListVo;
import com.zt.springcloud.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author RedReins
 * @version 1.0
 * @description: TODO
 * @date 2021/9/11 21:17
 */

@Component
public class OrderServiceImpl implements OrderService {
    @Autowired
    private RemoteOrderService remoteOrderService;
    @Autowired
    private RemoteUserService remoteUserService;

    @Override
    public Boolean createOrder(String reqData) {
        Long userId = remoteUserService.getUserInfo(TokenUtils.getUsername()).getId();
        return remoteOrderService.createOrder(reqData,userId);
    }

    @Override
    public List<OrderListVo> getUserAllOrder() {
        Long userId = remoteUserService.getUserInfo(TokenUtils.getUsername()).getId();
        return remoteOrderService.getUserAllOrder(userId);
    }

    @Override
    public Boolean deleteOrderItem(String orderId) {
        return remoteOrderService.deleteOrderItem(orderId);
    }
}
